#include "v.h"

#define SIZE	2

V::V()
{
	m_data = 0;
	m_size = 0;
	m_allocated = 0;
}

int V::size()
{
	return m_size;
}

int V::get(int a_index)
{
	return m_data[a_index];
}

void V::setSize(int a_newSize)
{
	m_size = a_newSize;
}

void V::add(int a_value)
{
	if(m_data == 0)
	{
		m_allocated = SIZE;
		m_data = new int[m_allocated];
	}
	if(m_size >= m_allocated)
	{
		int newSize = m_allocated + SIZE;
		int * tmp = new int[newSize];
		for(int i = 0; i < m_size; ++i)
		{
			tmp[i] = m_data[i];
		}
		delete [] m_data;
		m_data = tmp;
		m_allocated = newSize;
	}
	m_data[m_size++] = a_value;
}

int * V::getRawData()
{
	return m_data;
}